package com.itboye.jinpuyiyuan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itboye.jinpuyiyuan.R;
import com.itboye.jinpuyiyuan.bean.TestServerOrder;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/12/12 0012.
 */

public class TestServerPayGridAdapter extends BaseAdapter {
    private ArrayList<String> list;
    private Context context;
    private LayoutInflater inflater;
    public  TestServerPayGridAdapter(Context context,ArrayList<String> list){

        this.list=list;
        this.context=context;
        inflater=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder myViewHolder;
        if (convertView==null){
            myViewHolder=new MyViewHolder();
            convertView=inflater.inflate(R.layout.item_testserver_paygv,parent,false);
            myViewHolder.itemGv=convertView.findViewById(R.id.itemGv);
            convertView.setTag(myViewHolder);
        }else {
            myViewHolder= (MyViewHolder) convertView.getTag();
        }
        myViewHolder.itemGv.setText(list.get(position));
        if (position==(list.size()-1)){
            myViewHolder.itemGv.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.testsserver_pay_backbg));
            myViewHolder.itemGv.setTextColor(context.getResources().getColor(R.color.white));
       }
        return convertView;
    }

    class MyViewHolder{
        TextView itemGv;
    }
}
